//
//  HotViewController.m
//  ZhiHuiLiJiang
//
//  Created by Work on 2018/11/18.
//  Copyright © 2018年 王雅鹏. All rights reserved.
//已废弃

#import "HotViewController.h"
#import "HotCell.h"
#import "GuideSearchView.h"
#import "BYcitizenModel.h"

@interface HotViewController ()<NavigationViewDelegate,UITableViewDelegate,UITableViewDataSource>

@property (nonatomic ,strong) NavigationView * nagationView;

@property (nonatomic ,strong) UITableView * MainTableView;

@property (nonatomic ,strong) GuideSearchView * BgView;

@property(nonatomic,strong)NSArray *topicListDataArr;

@end

@implementation HotViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self hideNavigationBar:YES animated:YES];
    [self.view addSubview:self.nagationView];
    [self.view addSubview:self.BgView];
    [self.view addSubview:self.MainTableView];
    NSDictionary *dict3 = @{@"page":@"1",@"limit":@"10"};
    [self gettopicList:dict3];//热议列表

}

-(void)gettopicList:(NSDictionary *)dict{
    BY_kWeakSelf(ws);
    [BYNetworking requestGetOrPostWithType:GET url:LJURL_Vitizentopic_list params:dict success:^(NSInteger code, NSString * _Nonnull msg, id  _Nonnull data) {
        NSDictionary *dict = [data objectForKey:@"paginator"];
        NSArray *dataArr = dict[@"records"];
        NSMutableArray *dataArrM = [NSMutableArray arrayWithCapacity:dataArr.count];
        for (NSDictionary *dic in dataArr) {
            BYcitizenModel *topCarouselModel = [BYcitizenModel mj_objectWithKeyValues:dic];
            [dataArrM addObject:topCarouselModel];
            
        }
        ws.topicListDataArr = dataArrM.copy;
        [ws.MainTableView reloadData];
        
    } fail:^(NSError * _Nonnull error) {
        
    } showHUD:YES];

    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(GuideSearchView *)BgView{
    if (!_BgView) {
        _BgView = [[GuideSearchView alloc]initWithFrame:CGRectMake(0, 64, KSCREEWIDTH, 44)];
//        _BgView.AddssBtn.hidden = YES;
//        [_BgView.SeachBtn setTitle:@"搜索你感兴趣的事情" forState:UIControlStateNormal];
        _BgView.backgroundColor = [UIColor whiteColor];
    }
    return _BgView;
}

- (NavigationView *)nagationView{
    if (!_nagationView) {
        _nagationView = [[NavigationView alloc]initWithFrame:CGRectMake(0, 0, KSCREEWIDTH, 64) withLeftImageUrl:[NSArray arrayWithObjects:@"mainIcon_back",@"mainIcon_back",nil] withRighitImageUrl:nil withRightStr:nil withColor:nil];
        _nagationView.titleLabel.text = @"市民热议";
        _nagationView.backgroundColor = [UIColor whiteColor];
        _nagationView.delegate = self;
        _nagationView.titleLabel.textColor = [UIColor blackColor];
        _nagationView.rightBtn.hidden = YES;
    }
    return _nagationView;
}

- (UITableView *)MainTableView
{
    if (!_MainTableView) {
        _MainTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 108, KSCREEWIDTH, KSCREEHEGIHT  -108 ) style:UITableViewStylePlain];
        _MainTableView.delegate = self;
        _MainTableView.dataSource = self;
        _MainTableView.backgroundColor = [UIColor whiteColor];
        _MainTableView.tableFooterView = [UIView new];
        [_MainTableView registerClass:[HotCell class] forCellReuseIdentifier:@"HotCell"];
        
        
    }
    return _MainTableView;
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _topicListDataArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HotCell  *cell = [tableView dequeueReusableCellWithIdentifier:@"HotCell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.HimageView.image = [UIImage imageNamed:@"hotDiscussion_1"];
    cell.model =_topicListDataArr[indexPath.row];
    return cell;
}


#pragma mark - UITableViewDelegate -

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 260;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    BYHotContentViewController *contentVC = [[BYHotContentViewController alloc]init];
    [self.navigationController pushViewController:contentVC animated:YES];


}
-(void)navigtionleftBackclick:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
